#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
@Author:    Colin
@Github:    https://github.com/opscolin
@Gitee:     https://gitee.com/colin5063
@DateTime:  2022/9
@File:      config.py
@Software:  PyCharm
"""

import utils
import requests
import pushgateway

base_url = 'http://192.168.3.108:5005/'
instance_yml = 'instance.yml'

cfg = utils.get_config(instance_yml)

for instance_name in cfg.keys():
    print(f"Begin to push {instance_name}...")
    for db in utils.get_mysql_dbs(instance_name):
        dbname = db[0]

        # push rds disk metric
        disk_url = f"{base_url}/push/rds/disk?target={instance_name}"
        disk_res = requests.get(disk_url)

        db_url = f"{base_url}push/size/db?target={instance_name}&dbname={dbname}"
        db_res = requests.get(db_url)

        # for table in utils.get_mysql_db_tables(instance_name, dbname):
        #     tablename = table[0]
        #     table_url = f"{base_url}push/size/table?target={instance_name}&dbname={dbname}&tablename={tablename}"
        #     table_res = requests.get(table_url)
